#include "OLED.h"

extern Adafruit_SSD1306 display;
extern unsigned char sec,min,hou,lastsec, lastmin, lasthou;
extern bool flag;
extern long count1;
/********************************
   函数功能：显示时间和速度
   传入参数：无
   返回值: 无
 ********************************/
void oled_displayTimeandSpeed()
{
  if (sec >= 60)
  {
    sec = 0;
    flag = true;
    min++;
    if (min >= 60)
    {
      min = 0;
      hou++;
    }
  }

  display.clearDisplay();
  display.setTextSize(1);             // Normal 1:1 pixel scale
  display.setTextColor(SSD1306_WHITE);        // Draw white text
  //这部分显示时间
  //----------------------------------------------//
  display.setCursor(0, 0);            // Start at top-left corner
  display.println(F("Time:"));
  display.setCursor(45, 0);            // Start at top-left corner
  display.println(hou);
  display.setCursor(60, 0);            // Start at top-left corner
  display.println(F(":"));
  display.setCursor(75, 0);
  display.println(min);
  display.setCursor(95, 0);            // Start at top-left corner
  display.println(F(":"));
  display.setCursor(105, 0);
  display.println(sec);
  //----------------------------------------------//

  //这部分显示速度
  //---------------------------------------------//
  display.setCursor(0, 20);            // Start at top-left corner
  display.println(F("Speed:"));
  display.setCursor(45, 20);            // Start at top-left corner
  display.println(count1);
  display.setCursor(80, 20);            // Start at top-left corner
  display.println(F("r/min"));
  //-------------------------------------------//

  //这部分显示上次保存的数据
  //-----------------------------------------------//
  display.setCursor(0, 40);            // Start at top-left corner
  display.println(F("LastRunTime:"));
  display.setCursor(45, 50);            // Start at top-left corner
  display.println(lasthou);
  display.setCursor(60 , 50);            // Start at top-left corner
  display.println(F(":"));
  display.setCursor(75, 50);            // Start at top-left corner
  display.println(lastmin);
  display.setCursor(95, 50);            // Start at top-left corner
  display.println(F(":"));
  display.setCursor(105, 50);            // Start at top-left corner
  display.println(lastsec);
  display.display();
  //-------------------------------------------//
}
